{template '_header'}
<style>
    .multi-item {margin-bottom: 18px;}
</style>
<div class="page-heading">
    <span class="pull-right">
        <a class="btn btn-default btn-sm" href="{php echo webUrl('goods/group')}"><i class="fa fa-reply"></i> 返回列表</a>
    </span>
    <h2><i class="fa fa-circle-o"></i>{if !empty($item)}编辑{else}新建{/if}商品组 <small>{if !empty($item)}(名称: {$item['name']}){/if}</small></h2>
</div>

<form {ife 'goods.group' $item}action="" method="post"{/if} class="form-validate form-horizontal ">

    <div class="form-group">
        <label class="col-sm-2 control-label">商品组名称</label>
        <div class="col-sm-9">
            {ife 'goods.group' $item}
                <input type="text" class="form-control valid" name="name" value="{$item['name']}" data-rule-required="true" placeholder="请输入商品组名称" />
            {else}
                <div class='form-control-static'>{$item['name']}</div>
            {/if}
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">商品组状态</label>
        <div class="col-sm-9 col-xs-12">
            {ife 'goods.group' $item}
                <label class="radio-inline">
                    <input type="radio" name="enabled" value="1" {if $item['enabled']==1}checked="checked"{/if}> 启用
                </label>
                <label class="radio-inline">
                    <input type="radio" name="enabled" value="0" {if $item['enabled']==0 || empty($item)}checked="checked"{/if}> 禁用
                </label>
            {else}
                <div class='form-control-static'>{if $item['enabled']==1}启用{else}禁用{/if}</div>
            {/if}
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">组内商品</label>
        <div class="col-sm-9">
            <div class="form-group" style="height: auto; display: block;">
                <div class="col-sm-12 col-xs-12">
                    {ife 'goods.group' $item}
                        <?php echo tpl_selector('goodsids',array('preview'=>true,'readonly'=>true, 'required'=>'true', 'multi'=>1,'url'=>webUrl('goods/query'),'items'=>$goods,'buttontext'=>'选择商品','placeholder'=>'请选择商品'))?>
                    {else}
                        <div class="input-group multi-img-details container ui-sortable">
                            {loop $goods $item}
                            <div data-name="goodsid" data-id="426" class="multi-item">
                                <img src="{php echo tomedia($item['thumb'])}" class="img-responsive img-thumbnail">
                                <div class="img-nickname">{$item['title']}</div>
                            </div>
                            {/loop}
                        </div>
                    {/if}
                </div>
            </div>

        </div>
    </div>

    <table class='table'>
        <tr>
            <td>
                {ife 'goods.group' $item}
                    <input type="submit" class="btn btn-primary" value="保存">
                {/if}
            </td>
        </tr>
        </tbody>
    </table>

</form>

{ife 'goods.group' $item}
    <script language="javascript">
        require(['jquery.ui'],function(){
            $('.multi-img-details').sortable();
        })
    </script>
{/if}

{template '_footer'}